#include "ChartType.h"
namespace LightChart {
ChartType::ChartType(QWidget *parent) :
    QDialog(parent)
{
    setupUi(this);
    connect(finishButton, SIGNAL(clicked()), SLOT(finalize()));
}
void ChartType::finalize() {
    hide();
    ChartsStorage & cs = Storage::get_instance().charts;
    for (int i = 0; i < LineQuantity->value(); ++i)
        cs.add(new LineChart(parentWidget()));
    for (int i = 0; i < AreaQuantity->value(); ++i)
        cs.add(new AreaChart(parentWidget()));
    for (int i = 0; i < ScatterQuantity->value(); ++i)
        cs.add(new ScatterChart(parentWidget()));
    for (int i = 0; i < HistogramQuantity->value(); ++i)
        cs.add(new Histogram(parentWidget()));

    LineQuantity->setValue(0);
    ScatterQuantity->setValue(0);
    HistogramQuantity->setValue(0);
    AreaQuantity->setValue(0);
    ColumnQuantity->setValue(0);
    emit onFinishClicked();
}
}
